var records={
    data(){
        return {
            cmd_records_elements:{},     
        }
    },
    methods:{
        cmd_records_do:function(isRedo){  
            if(!this.cmd_records_elements[`${this.activePageIndex}`]) this.cmd_records_elements[`${this.activePageIndex}`]=[];  
            if(!this.cmd_redo_elements[`${this.activePageIndex}`]) this.cmd_redo_elements[`${this.activePageIndex}`]=[];        
            var data={eqstr:'',v:JSON.parse(JSON.stringify(this.pages[this.activePageIndex].items))};			
			data.v.forEach(item=>{
				data.eqstr+=`${item.x}-${item.y}-${item.width}-${item.height}`;	
				item.checked=false;			
			});
            var records = this.cmd_records_elements[`${this.activePageIndex}`];
			if((records.length>0 
			&& records[records.length-1].eqstr != data.eqstr)
			||records.length<=0){
				if(this.cmd_redo_elements[`${this.activePageIndex}`].length>0 && !isRedo){//在非重做操作时清空重做
                    this.cmd_redo_elements[`${this.activePageIndex}`]=[];                    
				}
				records.push(data);
				//console.log('push undoRecords:',this.pages[this.activePageIndex].undoRecords)
				if(records.length>=this.undoRecordsNum){
					records.shift();
				}
            }
            this.cmdActive['undo']=this.cmd_records_elements[`${this.activePageIndex}`].length>0;
            this.cmdActive['redo']=this.cmd_redo_elements[`${this.activePageIndex}`].length>0;
        },
        cmd_records_active:function(){

        }
    }
}

export default records;
